package com.hxzy.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxzy.common.annon.RequiresPermissions;
import com.hxzy.common.vo.R;
import com.hxzy.common.web.controller.BaseController;
import com.hxzy.service.SysDeptService;
import com.hxzy.system.dto.SysDeptSearchDTO;
import com.hxzy.system.entity.SysDept;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 科室
 * @author Administrator
 */
@Api(tags = "科室API")
@RestController
@RequestMapping(value = "/dept")
public class SysDeptController extends ExistsValueController {

    @Autowired
    private SysDeptService sysDeptService;

    @RequiresPermissions(value = "system:dept:list")
    @ApiOperation(value = "科室查询")
    @GetMapping(value = "/data")
    public R<List<SysDept>> search(SysDeptSearchDTO searchDTO){
        //排sorts排序
        QueryWrapper<SysDept> queryWrapper=new QueryWrapper<>();
        queryWrapper.orderByDesc("sorts").orderByAsc("id");
        List<SysDept> arr= this.sysDeptService.list(queryWrapper);
        return R.okHasData(arr);
    }

}
